﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace XHFrame
{
    public static class MethodExtension
    {
        /// <summary>
        /// 返回组件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="go"></param>
        /// <returns></returns>
        public static T GetOrAddComponent<T>(this GameObject go) where T : Component
        {
            T ret = go.GetComponent<T>();
            if (null == ret)
                ret = go.AddComponent<T>();
            return ret;
        }

     
    }
}
